package com.lxu.utils;


import freemarker.template.Configuration;
import freemarker.template.Template;
import org.jdom2.input.SAXBuilder;

import java.io.StringReader;
import java.io.StringWriter;
import java.util.Map;

public class FreemarkerUtil {

    /**
     * freemarker config
     */
    private static Configuration freemarkerConfig = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);

    /**
     * 填充模板
     * @return
     */
    public static String convert(String templateName, Map<String,Object> params) throws Exception{

        Template template =freemarkerConfig.getTemplate(templateName);

        StringWriter writer = new StringWriter();

        template.process(params,writer);

        String result =   writer.toString();

        anysisXML(result);

        return  result;
    }

    private static void anysisXML(String result) {
        StringReader reader = new StringReader(result);
        SAXBuilder builder = new SAXBuilder();

    }


}
